<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>订单记录</title>
	<link href="../css/public.css" rel="stylesheet"/>
	<link href="../css/main.css" rel="stylesheet"/>
	<link href="../css/style.css" rel="stylesheet"/>
	<link href="../css/agent.css?v=1" rel="stylesheet"/>
	<link href="../css/layer.css" rel="stylesheet"/>

	<script src="./js/jquery-1.9.1.js"></script>

	<script src="../js/swiper.min.js"></script>
	<script src="../js/mobile-util.js"></script>
	<script src="../js/public.js"></script>
	<script src="../js/layer/layui.js"></script>
	<script src="../js/jquery.cookie.js"></script>
    <script src="../../mifiadmin/js/common.js"></script>


	<script>
		/*获取url参数*/
		function getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg);  //匹配目标参数
			if (r != null) return unescape(r[2]); return null; //返回参数值
		}

		/*获取url参数end*/
	</script>



</head>
<body >

<header class="mui-bar mui-bar-nav indexheader bluebg flex">
	<div class="headerlogo" onclick="back()">
		<i class="iconfont backbtn">&#xe602;</i>
	</div>

	<div class="headertitle">
		<p>订单记录</p>
	</div>

	<div class="headerright timeright hide">
		<p class="timepbox iconfont">&#xe6d9;</p>
	</div>

</header>

<main class="agentbox">


	<div class="nulldecice">
		<p class="iconfont ">&#xe6ed;</p>
		<p class="nulldevicetitle">您还没有订单记录</p>
	</div>


	<div class="rachargbox">


		<!--<div class="racharglistbox">-->

			<!--<div class="flex racharghead">-->
				<!--<div class="rachargleft">订单金额</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--&yen 300-->
				<!--</div>-->
			<!--</div>-->

			<!--<div class="racharglist flex">-->
				<!--<div class="rachargleft">设备号</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--111111111-->
				<!--</div>-->
			<!--</div>-->

			<!--<div class="racharglist flex">-->
				<!--<div class="rachargleft">支付状态</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--已支付-->
				<!--</div>-->
			<!--</div>-->

			<!--<div class="racharglist flex">-->
				<!--<div class="rachargleft">套餐名称</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--3个月包月套餐-->
				<!--</div>-->
			<!--</div>-->


			<!--<div class="racharglist flex">-->
				<!--<div class="rachargleft">订单号</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--111111-->
				<!--</div>-->
			<!--</div>-->

			<!--<div class="racharglist flex">-->
				<!--<div class="rachargleft">订单时间</div>-->
				<!--<div class="rachargright te-ri">-->
					<!--2016-12-1-->
				<!--</div>-->
			<!--</div>-->


		<!--</div>-->



	</div>

	<div class="businessmore hide" onclick="ajax_sourch_submit()" >
		<p>查看更多</p>
		<p class="companyicon businessmoreicon">
			<i class="iconfont comicon">&#xe624;</i>
		</p>
	</div>






</main>


<script>

	var tooken=$.cookie("tooken");


	if(tooken==null||tooken==undefined||tooken==""){

		window.location.href="../agent/login.html";

	}else {
		var page = 1;
		var name=$.cookie("tooken");

		// var url="http://qt.hiberbest.com";
		//var url="http://192.168.0.132:69";
		var geturl=url+ "/Admin/agentapi/OrderList?tooken="+name+"&page=1&limit=5";

		$.ajax({
			type: 'get',
			dataType: "json",
			url: geturl,
			success: function (data) {
				console.log(data);
				var suc=data.success;
				if(suc.code == 4007){
					alert(suc.message);
					//window.location.href="login.html";
				}else if(suc.code == 4011) {
					alert(suc.message);
					//window.location.href = "login.html";
				}else if(suc.code == 4000){
					var OrderList=data.OrderList;
					var str="";

					if(OrderList.length == 0){
						$('.nulldecice').show();

						return false;
					}

					if(OrderList.length > 3){
						$('.businessmore').removeClass("hide");
					}


					for(var i=0;i<OrderList.length;i++){

						if(OrderList[i].paystate == 1){
							var paystate="已支付";
						}else{
							var paystate="未支付";
						}

						str+='<div class="racharglistbox">'+
								'<div class="flex racharghead">'+
								'<div class="rachargleft">订单金额</div>'+
								'<div class="rachargright te-ri">'+
								'&yen'+data.taocan[OrderList[i].goods_on].price+'</div>' +
								'</div>'+
								'<div class="racharglist flex">'+
								'<div class="rachargleft">设备号</div>'+
								'<div class="rachargright te-ri">'+
								''+ OrderList[i].device_id +''+
								'</div></div>'+
								'<div class="racharglist flex">'+
								'<div class="rachargleft">支付状态</div>'+
								'<div class="rachargright te-ri">'+
								''+paystate+''+
								'</div></div>'+
								'<div class="racharglist flex">'+
								'<div class="rachargleft">套餐名称</div>'+
								'<div class="rachargright te-ri">'+
								''+data.taocan[OrderList[i].goods_on].flow+''+
								'</div></div>'+
								'<div class="racharglist flex">'+
								'<div class="rachargleft">订单号</div>'+
								'<div class="rachargright te-ri">'+
								''+ OrderList[i].orderid +''+
								'</div></div>'+
								'<div class="racharglist flex">'+
								'<div class="rachargleft">订单时间</div>'+
								'<div class="rachargright te-ri">'+
								''+ OrderList[i].starttime +''+
								'</div></div></div>'

					}


					$('.rachargbox').html(str);
					$('.nulldecice').hide();


				}


			},error:function(data){
				alert("请检查您的网络");
			}
		});



		function ajax_sourch_submit() {


			page += 1;

			console.log(page);
			$.ajax({
				type : "GET",
				dataType: "json",
				url:url + "/Admin/agentapi/OrderList?tooken="+name+"&page="+page,
				success: function(data)
				{

					console.log(data);
					if(data.OrderList.length == 0){
						layui.use('layer', function(){
							var layer = layui.layer;

							layer.msg('没有更多数据了');
						});

					}else{

						var OrderList=data.OrderList;
						var str="";
						for(var i=0;i<OrderList.length;i++){

							if(OrderList[i].paystate == 1){
								var paystate="已支付";
							}else{
								var paystate="未支付";
							}

							str+='<div class="racharglistbox">'+
									'<div class="flex racharghead">'+
									'<div class="rachargleft">订单金额</div>'+
									'<div class="rachargright te-ri">'+
									'&yen'+data.taocan[OrderList[i].goods_on].price+'</div>' +
									'</div>'+
									'<div class="racharglist flex">'+
									'<div class="rachargleft">设备号</div>'+
									'<div class="rachargright te-ri">'+
									''+ OrderList[i].device_id +''+
									'</div></div>'+
									'<div class="racharglist flex">'+
									'<div class="rachargleft">支付状态</div>'+
									'<div class="rachargright te-ri">'+
									''+paystate+''+
									'</div></div>'+
									'<div class="racharglist flex">'+
									'<div class="rachargleft">套餐名称</div>'+
									'<div class="rachargright te-ri">'+
									''+data.taocan[OrderList[i].goods_on].flow+''+
									'</div></div>'+
									'<div class="racharglist flex">'+
									'<div class="rachargleft">订单号</div>'+
									'<div class="rachargright te-ri">'+
									''+ OrderList[i].orderid +''+
									'</div></div>'+
									'<div class="racharglist flex">'+
									'<div class="rachargleft">订单时间</div>'+
									'<div class="rachargright te-ri">'+
									''+ OrderList[i].starttime +''+
									'</div></div></div>'

						}



						$(".rachargbox").append(str);

					}
				}
			});
		}

	}



</script>


</body>
</html>
